package edu.ccut.saturn.authority.appinterface;

import java.sql.Connection;

import edu.ccut.saturn.component.SaturnData;
import edu.ccut.saturn.basecomponent.database.facade.factory.DBOperationFactory;

public class AuthorityServices {
	private static final String DEPARTMENT = "http://edu.ccut.saturn.authority.appinterface/data::SATURN_AUTHORITY_DEPARTMENT";
	private static final String RES_LOCK = "http://edu.ccut.saturn.authority.appinterface/data::SATURN_AUTHORITY_RES_LOCK";
	private static final String RESOURCE = "http://edu.ccut.saturn.authority.appinterface/data::SATURN_AUTHORITY_RESOURCE";
	private static final String ROLE_DEPT = "http://edu.ccut.saturn.authority.appinterface/data::SATURN_AUTHORITY_ROLE_DEPT";
	private static final String ROLE_RES = "http://edu.ccut.saturn.authority.appinterface/data::SATURN_AUTHORITY_ROLE_RES";
	private static final String ROLE = "http://edu.ccut.saturn.authority.appinterface/data::SATURN_AUTHORITY_ROLE";
	private static final String USER_ROLE = "http://edu.ccut.saturn.authority.appinterface/data::SATURN_AUTHORITY_USER_ROLE";
	private static final String USER = "http://edu.ccut.saturn.authority.appinterface/data::SATURN_AUTHORITY_USER";
	static AuthorityServices instance = new AuthorityServices();

	private AuthorityServices() {
	}

	public static AuthorityServices getInstance() {
		return instance;
	}

	public static SaturnData getDeptInfo(String deptId, Connection conn)
			throws Exception {
		return DBOperationFactory.QueryByPrimaryKey().execute(DEPARTMENT,
				deptId, conn);
	}

	public static SaturnData getUserInfo(String userId, Connection conn)
			throws Exception {
		return DBOperationFactory.QueryByPrimaryKey().execute(USER, userId,
				conn);
	}

	public static SaturnData getRoleInfo(String roleId, Connection conn)
			throws Exception {
		return DBOperationFactory.QueryByPrimaryKey().execute(ROLE, roleId,
				conn);
	}

	public static SaturnData getResourceInfo(String resourceId, Connection conn)
			throws Exception {
		return DBOperationFactory.QueryByPrimaryKey().execute(RESOURCE,
				resourceId, conn);
	}
}
